
<div class="comment-widget">
  <div class="comment-edit">
    <form id="commentform_<?php echo $tid;?>" method="post" action="<?php echo url('member/snsindex/addcomment');?>?t=1">
      <input type="hidden" name="originaltype" value="<?php echo $type;?>"/>
      <input type="hidden" name="originalid" value="<?php echo $tid;?>"/>
      <input type="hidden" name="showtype" value="<?php echo $showtype;?>"/>
      <div class="comment-add">
        <textarea placeholder="我也插句话..." resize="none" id="content_comment<?php echo $tid;?>" name="commentcontent"></textarea>
        <span class="error"></span> 
        <!-- 验证码 -->
        <div id="commentseccode<?php echo $tid;?>" class="seccode" style="display: none;">
          <label for="captcha">验证码：</label>
          <input name="captcha" class="text" type="text" size="4" maxlength="4"/>
          <img src="" title="点击更换验证码" name="codeimage" onclick="this.src='<?php echo url('seller/sellerlogin/verify_code')?>&t=' + Math.random()"/> <span>您的操作过度频繁，请输入验证码后继续。</span>
          <input type="hidden" name="nchash" value="<?php echo $nchash;?>"/>
        </div>
        <input type="text" style="display:none;" />
        <!-- 防止点击Enter键提交 -->
        <div class="act"> <span class="skin-blue"><span class="btn"><a href="javascript:void(0);" nc_type="commentbtn" data-param='{"txtid":"<?php echo $tid;?>"}'>评论</a></span></span> <span id="commentcharcount<?php echo $tid;?>" style="float:right;"></span> <a class="face" nc_type="smiliesbtn" data-param='{"txtid":"comment<?php echo $tid;?>"}' href="javascript:void(0);" >表情</a> </div>
      </div>
    </form>
  </div>
  <div class="clear"></div>
  <?php if (count($commentlist)>0){ ?>
  <ul class="comment-list">
    <?php foreach ((array)$commentlist as $k=>$v){?>
    <li nc_type="commentrow_<?php echo $v['comment_id']; ?>"> <a target="_blank" href="<?php echo url('member/snshome/index');?>?mid=<?php echo $v['comment_memberid'];?>"><img width="30" height="30" class="clogo" src="<?php echo $v['comment_memberavatar'];?>" onload="javascript:DrawImage(this,30,30);"></a>
      <div class="detail">
        <p class="words"><a target="_blank" href="<?php echo url('member/snshome/index');?>?mid=<?php echo $v['comment_memberid'];?>" class="name"><?php echo $v['comment_membername'];?></a>：<?php echo parsesmiles($v['comment_content']);?></p>
        <p class="other">
          <?php if (session('member_id') == $v['comment_memberid']){?>
          <span class="opt"><a href="javascript:void(0);" nc_type="comment_del" data-param='{"cid":"<?php echo $v['comment_id'];?>"}'>删除</a></span>
          <?php }?>
          <span class="time"><?php echo @date('Y-m-d H:i',$v['comment_addtime']);?> - <?php echo $k+1;?>&nbsp;楼</span> </p>
      </div>
    </li>
    <?php }?>
  </ul>
  <?php if ($showtype==1 && $showmore == '1'){?>
  	<!--//展示更多连接-->
  <div class="more"><a target="_blank" href="<?php echo url('/member/snshome/traceinfo');?>?mid=<?php echo $master_info['member_id'];?>&id=<?php echo $tid;?>">查看更多评论</a></div>
  <?php } elseif (!$showtype){?>
  	<!--//展示分页-->
  <div class="pagination"><?php echo $show_page; ?></div>
  <?php } ?>
  <?php } ?>
  <div style="clear:both;"></div>
</div>
<script type="text/javascript">
$(function(){
	//删除评论
	$("[nc_type='comment_del']").live('click',function(){
		var obj = $(this);
		showDialog('您确定要删除该信息吗？','confirm', '', function(){
			var data_str = $(obj).attr('data-param');
	        eval("data_str = "+data_str);
	        ajax_get_confirm('',"<?php echo url('member/snsindex/delcomment');?>?id="+data_str.cid);
			return false;
		});
	});
	//评论提交
	$("[nc_type='commentbtn']").die().live('click',function(){
		var data = $(this).attr('data-param');
        eval("data = "+data);
		if($("#commentform_"+data.txtid).valid()){			
			var cookienum = $.cookie('<?php echo COOKIE_PRE;?>commentnum');
			cookienum = parseInt(cookienum);
			if(cookienum >= <?php echo $max_recordnum;?> && $("#commentseccode"+data.txtid).css('display')=="none"){
				//显示验证码
				$("#commentseccode"+data.txtid).show();
				var nchash = $("#commentseccode"+data.txtid).find("[name='nchash']").val();
				$("#commentseccode"+data.txtid).find("[name='codeimage']").attr('src',"<?php echo url('/seller/sellerlogin/verify_code');?>&t=" + Math.random());
			}else if(cookienum >= <?php echo $max_recordnum;?> && $("#commentseccode"+data.txtid).find("[name='captcha']").val() == ''){
				showDialog('请填写验证码');
			}else{
				ajaxpost('commentform_'+data.txtid, '', '', 'onerror');
				//隐藏验证码
				$("#commentseccode"+data.txtid).hide();
				$("#commentseccode"+data.txtid).find("[name='codeimage']").attr('src','');
				$("#commentseccode"+data.txtid).find("[name='captcha']").val('');
			}
		}
		return false;
	});
	$('#commentform_<?php echo $tid;?>').validate({
		errorPlacement: function(error, element){
			element.next('.error').append(error);
	    },      
	    rules : {
	    	commentcontent : {
	            required : true,
	            maxlength : 140
	        }
	    },
	    messages : {
	    	commentcontent : {
	            required : '需要评论点内容~',
	            maxlength: '不能超过140字'
	        }
	    }
	});
	<?php if (!$showtype==1){?>
	//分页绑定异步加载事件
	$('#tracereply_<?php echo $tid;?>').find('.demo').ajaxContent({
		event:'click',
		loaderType:"img",
		loadingMsg:"<?php echo SHOP_TEMPLATES_URL;?>/images/transparent.gif",
		target:'#tracereply_<?php echo $tid;?>'
	});
	<?php }?>
	//评论字符个数动态计算
	$("#content_comment<?php echo $tid;?>").charCount({
		allowed: 140,
		warning: 10,
		counterContainerID:'commentcharcount<?php echo $tid;?>',
		firstCounterText:'还可以输入',
		endCounterText:'字',
		errorCounterText:'已经超出'
	});
});
</script>